package cn.wyj.basic.config;

import cn.wyj.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加我们的登录拦截器
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") // 设置拦截所有
                .excludePathPatterns( // 设置拦截器放行路径
                        // 放行登录相关接口
                        "/login/**",

                        // 放行验证码相关接口
                        "/verifyCode/**",

                        // 放行图形验证码相关接口
                        "/fastdfs/**",

                        // 放行店铺入驻接口
                        "/shop/settlement",

                        // 放行手机注册接口
                        "/register/phone"


                    );

    }
}
